﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PNTSystemClass.Framework.Console;

namespace PNTSystemClass.SystemClass
{
    class SystemClass
    {
        public static object GetVarValue(string v_name)
        {
            int i = 0;
            foreach(string vname in Vars.varString)
            {
                if(vname == v_name)
                {
                    return Convert.ChangeType(Vars.varVal[i], Vars.varType[i]);
                }
                i++;
            }
            return -1;
        }

        public static object GetConstVarValue(string cv_name)
        {
            int i = 0;
            foreach (string vname in Vars.constVarString)
            {
                if (vname == cv_name)
                {
                    return Convert.ChangeType(Vars.constVarVal[i], Vars.constVarType[i]);
                }
                i++;
            }
            return -1;
        }

        public static Type GetVarType(string v_name, List<TypeCode> typeCodes, List<string> vars)
        {
            int i = 0;
            foreach (string vname in vars)
            {
                if (vname == v_name)
                {
                    return Type.GetType("System." + Enum.GetName(typeof(TypeCode), typeCodes[i]));
                }
                i++;
            }
            return (Type)Type.Missing;
        }

        public static string GetStringValue(string @value)
        {
            return value.Replace("\"", "");
        }
    }
}
